package com.yangfan.design_pattern.observer;

/**
 * @description:
 * @author: yangfan
 * @date: Created in 2020/2/10 0010 16:46
 * @modified By:
 */
public class ObServerTest {

    public static void main(String[] args) {

        //创建公告
        Subject subject = new Subject();//通知

        //创建订阅者
        new ObServer("张三", subject);
        new ObServer("李四", subject);

        subject.update("17号上班，之前时间在家办公");//公告内容修改,当内容修改后就会通知 订阅者


        try {
            Thread.sleep(5_000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println("===========================================");


        //新增一个订阅者
        new ObServer("王五", subject);

        subject.update("计划有变！3月之前都无法上班!");



    }

}
